import request from './index';


// 保存会话数据
export const saveSessionApi = async (sessionName: string): Promise<any> => {
  try {
    return await request.post('/saveSession', {
      sessionName
    });
  } catch (error) {
    console.error('保存会话数据失败:', error);
    throw error;
  }
};


// 获取会话列表
export const getSessionListApi = async (): Promise<any> => {
  try {
    return await request.get('/getSessions');
  } catch (error) {
    console.error('获取会话列表失败:', error);
    throw error;
  }
};
// 保存问答记录
export const saveMessageApi = async (sessionId: string, messageType: string, content: string, messageId?: string): Promise<any> => {
  try {
    return await request.post('/saveMessage', {
      sessionId,
      messageType,
      content,
      messageId
    });
  } catch (error) {
    console.error('保存问答记录失败:', error);
    throw error;
  }
};



// 获取对话记录1
export const getMessagesApi = async (sessionId: string): Promise<any> => {
  try {
    return await request.get('/getMessages', {
      params: {
        sessionId
      }
    });
  } catch (error) {
    console.error('获取对话记录失败:', error);
    throw error;
  }
};

// 删除会话
export const deleteSessionApi = async (sessionId: string): Promise<any> => {
  try {
    return await request.post('/deleteSession', {
      sessionId
    });
  } catch (error) {
    console.error('删除会话失败:', error);
    throw error;
  }
};
